package com.yl.auth.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yl.auth.entity.Fangjian;
import com.yl.auth.entity.Louceng;
import com.yl.auth.model.entity.Chuangwei;
import com.yl.auth.model.vo.ChaFangVo;
import com.yl.auth.service.ChafangjiluService;
import com.yl.auth.service.ChuangweiService;
import com.yl.auth.service.FangjianService;
import com.yl.auth.service.LoucengService;
import com.yl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.xml.bind.ValidationEvent;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author L
 * @since 2023-07-19
 */
@Api(tags = "医护管理-查房管理")
@RestController
@RequestMapping("/admin/auth/chafangjilu")
public class ChafangjiluController {
    @Resource
    private ChafangjiluService chafangjiluService;
    @Resource
    private LoucengService loucengService;
    @Resource
    private FangjianService fangjianService;
    @Resource
    private ChuangweiService chuangweiService;

    /**
     * 医生查房记录
     */
    @ApiOperation(value = "医生查房记录")
    @GetMapping("/getChangFang/{page}/{limit}")
    public Result getChangFang(@PathVariable @ApiParam("页码") Long page,
                               @PathVariable @ApiParam("记录") Long limit,
                               @ApiParam("老人姓名") String name,
                               @ApiParam("床位") String chuangwei,
                               @ApiParam("记录时间") Date jiluTime){
        Page<ChaFangVo> page1=new Page<>(page,limit);
        Page<ChaFangVo> list=chafangjiluService.getChangFang(page1,name,chuangwei,jiluTime);
//        ChaFangVo chaFangVo=new ChaFangVo();
//        //查楼层
//        List<Louceng> lclist=loucengService.list();
//        //查房间
//        List<Fangjian> flist=fangjianService.list();
//        //查床位
//        List<Chuangwei> clist=chuangweiService.list();
//        //全部查出来之后进行循环拼接(楼层/房间/床位)
//        for (Louceng louceng : lclist) {
//            for (Fangjian fangjian : flist) {
//                for (Chuangwei chuangwei : clist) {
//                    if(louceng.getId()==fangjian.getFloorId()&&fangjian.getId()==chuangwei.getRoomId()){
//                        chaFangVo.setChuangwei(louceng.getName()+"/"+fangjian.getRoomNo()+"/"+chuangwei.getBedNo());
//                        System.out.println(chaFangVo.getChuangwei());
//                    }
//                }
//            }
//        }

        return Result.ok(list);
    }

    /**
     * 根据id查房详情老人基本信息
     */
    @ApiOperation(value = "查房详情-老人基本信息")
    @GetMapping("/getLaoren/{id}")
    public Result getLaoren(@PathVariable @ApiParam("查房id") Integer id){
        ChaFangVo chaFangVo=chafangjiluService.getLaoren(id);
        return Result.ok(chaFangVo);
    }

    /**
     * 查房详情老人身体基本情况
     */
    @ApiOperation(value = "查房详情老人身体基本情况")
    @GetMapping("/getLaorenshenti/{id}")
    public Result getLaorenshenti(@PathVariable @ApiParam("查房id") Integer id){
        ChaFangVo cfv=chafangjiluService.getLaorenshenti(id);
        return Result.ok(cfv);
    }

    /**
     * 查房详情老人生命特征
     */
    @ApiOperation(value = "查房详情老人生命特征")
    @GetMapping("/getLaorenshengming/{id}")
    public Result getLaorenshengming(@PathVariable @ApiParam("查房id") Integer id){
        ChaFangVo cf=chafangjiluService.getLaorenshengming(id);
        return Result.ok(cf);
    }
}

